package com.wsc.wisdomchinaqinghe.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wsc.wisdomchinaqinghe.R;

import java.util.List;

/**
 * 四大功能适配器
 * Created by ${wangtao} on 2017/2/24.
 */

public class LifeServerAdapter extends BaseAdapter {
    private List<String> objects;
    private Context context;
    private LayoutInflater layoutInflater;

    public LifeServerAdapter(Context context, List<String> objects) {
        this.objects = objects;
        this.context = context;
        this.layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return objects.size();
    }

    @Override
    public String getItem(int position) {
        return objects.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.item_lifeserveradapter, null);
            convertView.setTag(new LifeServerAdapter.ViewHolder(convertView));
        }
        initializeViews((String) getItem(position), (LifeServerAdapter.ViewHolder) convertView.getTag());
        return convertView;
    }

    private void initializeViews(String object, LifeServerAdapter.ViewHolder holder) {
        //TODO implement
        Glide.with(context).load(object)
//                .placeholder(R.mipmap.own_pic_logout)
//                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(holder.itemHeadImg);
//            holder.itemHeadName.setText(object.getTitle());

    }

    protected class ViewHolder {
        private ImageView itemHeadImg;
//        private TextView itemHeadName;

        public ViewHolder(View view) {
            itemHeadImg = (ImageView) view.findViewById(R.id.item_sida_gongnneg_head_img);
//            itemHeadName = (TextView) view.findViewById(R.id.item_sida_gongnneg_head_name);
        }
    }
}
